import Mock from 'mockjs'
Mock.setup({timeout:'100-200'})
// 登录数据
const login=(url,way)=>{
    Mock.mock(url,way,function(params){
        try{
            const { username,password }=JSON.parse(params.body);
            if( username && password ) {
                return ({
                    code:200,
                    message:'success'
                })
            }
        }catch(e){
                return ({ 
                    code:404,
                    message:e.message
            })
        }
    })
}

// 注册数据
const register =(url,way)=>{
    Mock.mock(url,way,function(params){
            try{
                const { username,password }=JSON.parse(params.body);
                if( username && password ) {
                    return({ 
                        code:200,
                        message:'success'
                    })
                }
            } catch(e) {
                return { code:404, message:e.message}
            }
    })
} 

export default {
    login,register
}